package com.weharvest.edu.dao.mapper;

import com.weharvest.edu.entity.BackstageMenu;
import com.weharvest.edu.entity.BackstageRole;
import com.weharvest.edu.entity.BackstageUser;
import com.weharvest.edu.entity.between.BackstageUserInfo;
import com.weharvest.edu.view.BackstageUserDetailView;
import com.weharvest.edu.view.save.BackstageUserInfoSave;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface BackstageUserDaoMapper extends BaseDaoMapper {

    /**
     * 关联查询 根据用户id去查询该后台用户detail信息
     * @param uid
     * @return
     */
    BackstageUserDetailView queryByBackstageUserDetail(String uid);

    /**
     * 关联查询 根据用户id去查询该用户拥有多少个菜单列表
     * @param backstageUser
     * @return
     */
    List<BackstageMenu> queryByBackstageMenus(BackstageUser backstageUser);


    /**
     * 关联查询 + 根据用户查询角色
     *
     * @param params
     * @return
     */
    BackstageRole queryByBr(@Param("params") Map<String, Object> params);



    /**
     * 闭包查找子级 +角色属性
     *
     * @param params
     * @return
     */
    BackstageUserInfoSave queryByClosureBuAndBrChildren(@Param("params") Map<String, Object> params);

    /**
     * 闭包查找子级
     *
     * @param params
     * @return
     */
    BackstageUserInfoSave queryByClosureBuChildren(@Param("params") Map<String, Object> params);


    /**
     * 闭包查找父级
     *
     * @param params
     * @return
     */
    BackstageUserInfoSave queryByClosureBuParent(@Param("params") Map<String, Object> params);

    /**
     * 闭包查找父级+批量+角色属性
     *
     * @param params
     * @return
     */
    List<BackstageUserInfoSave> queryByClosureBuAndBrInParent(@Param("params") Map<String, Object> params);


    /**
     * 闭包查找父级
     *
     * @param params
     * @return
     */
    BackstageUserInfoSave queryByClosureBu(@Param("params") Map<String, Object> params);


    /**
     * 增加用户闭包表
     *
     * @param backstageUserInfo
     */
    void addByBackstageUserInfo(List<BackstageUserInfo> backstageUserInfo);

    /**
     * 修改
     *
     * @param params
     * @return
     */
    int modify(@Param("params") Map<String, Object> params);
}
